def hrop(x):
	if x == 0 or x == 1:
		return 1
	return x*hrop(x-1)

def fjoldi(folk):
	moguleikar = folk**2 - folk
	moguleikar2 = 1
	i=1
	while moguleikar-2*folk-3*i > 0:
		moguleikar2 *= moguleikar -2*folk -3*i
		i += 1
	return moguleikar2

	
			
			


profanir = int(input())

tilvik = []
for x in range(profanir):
	tala = int(input())
	tilvik.append(tala)
	print(fjoldi(tala))
	
